<template>
	<om-formsub-outer :index="index">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {subOnLoad, changeEditor,configSelectData} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return {
				initValue:{
					userId:"",
					userName:"",
					postId:"",
					postName:""
				},
				autoformdata: [],
				cachename:'',
				index:null,
				datas:[],
				order:0,
				formdata:{},
				postId:""
			}
		},
		methods: {
			onSelectUserPost(data){
				var row = this.$refs.autoform.formdata
				row.userId = data.userId;
				row.userName = data.userName;
				row.postId = data.posId;
				row.postName = data.posName;
			},
			initLoad(){
				let _that = this
				_that.om.request("tradeData/getIndirectParentPostData",{postId:this.postId}).then(res=>{
					//if(res instanceof Array){
					if(Object.prototype.toString.call(res)==='[object Array]'){
						_that.$refs.autoform.changeEditor('title6',"userPostId","data",configSelectData(res,"id","userPosName"))
					}else if(res.msg){
						_that.om.toast(res.msg)
					}
				})
			}
		},
		onLoad(e){
			let _that = this
			subOnLoad(_that, e, function() {
				_that.postId = e.postId
				if(e.configDataCacheKey){
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							//if(res.data && res.data instanceof Array){
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
								Object.assign(_that.initValue, _that.formdata)
								_that.autoformdata[0].order = _that.order
								_that.initLoad()
							}
						}
					});
				}
			})
		}
	}
</script>
